home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: gusty@clark.net (Harlan Messinger)
- Newsgroups: comp.lang.c++
- Subject: Re: Need help in C
- Date: 24 Jan 1996 17:52:30 GMT
- Organization: Clark Internet Services, Inc., Ellicott City, MD USA
- Message-ID: <4e5rku$9jo@clarknet.clark.net>
- References: <4e4h29$3f2@cville-srv.wam.umd.edu>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- David Leung (leungyl@wam.umd.edu) wrote:
- : I am studying C/C++ and I arrived at a problem that I am stuck with.
- : I think it is easy for expericenced programmers, if you can help me
- : please email me at leungyl@wam.umd.edu
- :
- : this is the problem
- :
- : input a five digit number
- :
- : then, separate the five digits into 5 separate numbers and evaluate them
- : independently. Basically, cut the number into five pieces. This is what
- : I wrote.....
- :
- : cout << "Enter a five digit number: ";
- :
- : cin >> input;
- :
- :
- :
- : digi1 = input / 10000;
- :
- : digi2 = input / 1000 - digi1 * 10;
- :
- : digi3 = input / 100 - digi1 * 100 - digi2 * 10;
- :
- : digi4 = input / 10 - digi1 * 1000 - digi2 * 100 - digi3 * 10;
- :
- : digi5 = input - digi1 * 10000 - digi2 * 1000 - digi3 * 100 - digi4 * 10;
- :
- :
- :
- : cout << input << endl;
- :
- : cout << digi1 << endl;
- :
- : cout << digi2 << endl;
- :
- : cout << digi3 << endl;
- :
- : cout << digi4 << endl;
- :
- : cout << digi5 << endl;
- :
- :
- :
- :
- :
- : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- : the problem is, it work for some numbers, but for others it doesn't work.
- : Why? Can somebody help me??Thanks very much.
- :
-
- "It doesn't work" isn't much of a clue! What do you mean by "it doesn't
- work"? What does happen? What numbers does it work for, and what numbers
- doesn't it work for?
-
- Also, how do you have input, dig1, etc., declared?
-